package siau.android.base

import android.content.Context
import hhm.android.library.LogUtils
import io.flutter.embedding.android.FlutterFragment
import io.flutter.plugin.common.MethodChannel

class MyFlutterFragment : FlutterFragment() {
    private var channel: MyMethodChannel? = null

    override fun onAttach(context: Context) {
        super.onAttach(context)

        channel = MyMethodChannel.registerWith(activity, flutterEngine?.dartExecutor)
    }

    fun sendMessageToFlutter(data: String) {
        channel?.invokeMethod("refresh", data)
    }

    override fun onDestroy() {
        if (null != channel) {
            channel?.release()
            channel = null
        }
        super.onDestroy()
    }
}